package com.wjm.demo.test1.net_test.tcp_socket_test.texttrans;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class TransServer {

    public static void main(String[] args) throws Exception {
        ServerSocket ss = new ServerSocket(10001);
        Socket accept = ss.accept();
        String ip = ss.getInetAddress().getHostAddress();
        System.out.println(ip + ".......connected");
        BufferedReader br = new BufferedReader(new InputStreamReader(accept.getInputStream()));
        PrintWriter pw = new PrintWriter(accept.getOutputStream(),true);//自动刷新
        String line = null;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
//            pw.print(line.toUpperCase()+"\r\n");
//            pw.flush();
            pw.println(line.toUpperCase());
        }
        accept.close();
        ss.close();
    }
}
